<template>
  <div class="mui-pages">
    <header class="mui-bar mui-bar-nav flex-justify-start">
      <div @click="fn.back()" class="mui-action-back"><img class="back-btn" src="../../../../static/images/back.png"></div>
      <h1 class="mui-title">学习答题情况</h1>
    </header>
    <div class="mui-page-content">
      <div class="mui-scroll-wrapper">
        <div class="mui-scroll">
          <div class="statistics-header">
            <h4>{{studyAnswerSituationItem.partyGroupName}}</h4>
            <p class="record-lists work-message-item-worlds">{{studyAnswerSituationItem.year}}年{{studyAnswerSituationItem.month}}月份党支部学习安排</p>
          </div>
          <ul class="mui-table-view organization-lists">
            <li class="mui-table-view-cell" @click="go(item)" v-for="item in list">
              <div class="mine-lists-content ">
                <h2 class="organization-lists-title">周度学习主题：{{item.subject}}</h2>
                <div class="flex-between-center mine-lists-tips">
                  <p v-if="item.studyBeginTime === null || item.studyBeginTime === ''">答题时间：未开放</p>
                  <p v-if="item.studyBeginTime !== null && item.studyBeginTime !== ''">答题时间：{{item.studyBeginTime}}至{{item.studyEndTime}}</p>
                  <span v-if="item.studyBeginTime === null || item.studyBeginTime === ''">未开放</span>
                  <span v-if="!item.finished && item.studyBeginTime !== null && item.studyBeginTime !== ''" class="mine-lists-money">未完成</span>
                  <span v-if="item.finished">已完成</span>
                </div>
              </div>
            </li>
          </ul>
          <noData v-if="list.length<1 && !isLoading"></noData>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import tools from '@/utils/tools'
  import loginService from '@/service/loginService'
  export default {
    name: 'studyAnswerSituation',
    data () {
      return {
        fn: tools,
        isLoading: true,
        list: [],
        studyAnswerSituationItem: {}
      }
    },
    created () {
      this.studyAnswerSituationItem = this.$store.state.studyAnswerSituationItem
      this.loadData()
    },
    methods: {
      loadData () {
        let userInfo = this.$store.state.userInfo
        let partyGroupId = userInfo.partyMemberModel.partyGroupId
        let yearMonth = this.studyAnswerSituationItem.year + '-' + this.studyAnswerSituationItem.month
        let data = {
          partyGroupId: partyGroupId,
          yearMonth: yearMonth
        }
        this.isLoading = true
        loginService.getPartyGroupAnswer(data).then(res => {
          this.isLoading = false
          if (res.code !== 200) {
            return tools.tip(res.message)
          }
          this.list = res.data
        })
      },
      go (item) {
        if (item.studyBeginTime === null || item.studyBeginTime === '') {
          tools.alert('本次答题暂未开放，无对应答题情况')
        } else {
          // 保存此条信息
          this.$store.state.answerSituationItem = item
          this.$router.push({path: '/answerSituation'})
        }
      }
    }
  }
</script>

<style scoped>

</style>
